import { ref } from "vue"

const useYearHooks = function (fetchData: any) {
  const year = ref(String(new Date().getFullYear() - 1))
  const persons = ref<any>([])

  function getData() {
    fetchData({
      year: year.value
    }).then((res: any) => {
      if (res.code === 200) {
        persons.value = res.data
      }
    })
  }
  return {
    getData,
    year,
    persons
  }
}

export default useYearHooks